package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.BaseContext;
import com.itheima.reggie.common.R;
import com.itheima.reggie.dto.OrdersDto;
import com.itheima.reggie.pojo.Orders;
import com.itheima.reggie.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Base64;

/**
 * 订单管理
 */
@RestController
@RequestMapping("order")
public class OrdersController {

    @Autowired
    private OrdersService ordersService;

    @GetMapping("page")
    public R<Page<OrdersDto>> page(Integer page,Integer pageSize){
        Page<OrdersDto> ordersPage1 = ordersService.dtoPage(page,pageSize);
        return R.success(ordersPage1);
    }

    @GetMapping("userPage")
    public R<Page<OrdersDto>> userPage(Integer page,Integer pageSize){
        Page<OrdersDto> ordersPage = ordersService.dtoPage(page,pageSize);
        return R.success(ordersPage);
    }

    @PostMapping("submit")
    public R<String> postSubmit(@RequestBody Orders orders){
        ordersService.submitOrders(orders);
        return R.success("提交成功");

    }

}
